import logging,HTMLTestRunner_cn,yagmail,pytest
from time import sleep
import os.path

from chardet.cli.chardetect import description_of
from django.template.defaultfilters import title


class Tools():
    #日志
    def Log1(self):
        log = logging.basicConfig(level=logging.DEBUG,
                                   format='%(levelname)s %(message)s %(asctime)s'
                                          ' %(filename)s %(lineno)d',
                                   filename='A3mall.log', filemode='a+')
        return log

    def Log1(self):
        log = logging.basicConfig(level=logging.DEBUG,format='%(levelname)s' '%(message)s' '%(asctime)s' '%(filename)s' '%(lineno)d' ,
                                  filename='jx。log',filemode='a+')
    def Log1(self):
        log = logging.basicConfig(level=logging.DEBUG,format= '%(levelname)s' '%(filename)s' '%(asctime)s' ' %(message)s' '%(lineno)d',filename='jx.log',filemode='w+')
    #报告
    def Report(self):
        report1 = HTMLTestRunner_cn.HTMLTestRunner(open('./jx.html','wd'),title='jx业务测试报告',description = 'jx项目实现数据驱动，测试结果，生成测试报告')
        return    report1

    def baogao(self):
        baogao1 = HTMLTestRunner_cn.HTMLTestRunner(open('/.jx.html','wd'),title='jx业务报告',description='jx项目实现数据驱动')

        return baogao1


    #邮件
    def Email(self):
        email = yagmail.SMTP(user='3484055372@qq.com',password='ufxzgmbqqnyhciji',host='smtp.qq.com',port=465)
        email.send(to='3484055372@qq.com',subject='jx版本测试结果',contents=['执行了5条用例，均通过测试','./jx.log'])
        email.close()

if __name__ == '__main__':
    pytest.main([])